<?php

namespace Cyv\Laravel;

trait HttpResponse
{
    /**
     * @param $data
     * @return false|string
     */
    public function success($data = [])
    {
        return response()->json([
            'code' => 0,
            'msg'  => 'success',
            'data' => $data
        ]);
    }

    /**
     * @param $msg
     * @param $code
     * @return false|string
     */
    public function error($msg = 'error', $code = 500)
    {
        return response()->json([
            'code' => $code,
            'msg'  => $msg,
            'data' => []
        ]);
    }
}